Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Showing means and standard deviation in the same in*Stata table

    Hi everyone,
    I am trying to use the table command in Stata17 to generate a table with means and SD displayed in the the same line.
    If you run the following commands:

    Code:
    webuse nhanes2l, clear
    table ( var ) ( sex ) (), statistic(frequency) statistic(mean age height weight) statistic(sd age height weight) nformat(%9.1g percentile) nformat(%9.1f mean sd)
    This generates a table with means and standard deviations in seperate line for each variable

    What I am hoping to achieve is to get the mean (SD) in the same row.
    Is there a way?
    Thanks

  • #2
    Am Ma:
    welcome to this forum.
    Do you mean something like:
    Code:
    . use "C:\Program Files\Stata17\ado\base\a\auto.dta"
    (1978 automobile data)
    
    . tabstat price, stats(mean sd)
    
        Variable |      Mean        SD
    -------------+--------------------
           price |  6165.257  2949.496
    ----------------------------------
    
    .
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment


    • #3
      Carlo Lazzaro Thank you
      I should have been more clear in my post, apologies.
      I am hoping to achieve something like the following, is it possible?
      Sex
      Male Female Total
      Frequency 4,915 5,436 10,351
      Age, mean(SD) 47.4 (17.2) 47.7 (17.3) 47.6 (17.2)

      Comment


      • #4
        Am:
        have you already taken a look at the community-contributed module -asdoc-?
        Kind regards,
        Carlo
        (StataNow 18.5)

        Comment


        • #5
          take a look at the 7-part Stata blog on use of the new -table- command; in particular, look at part e: https://blog.stata.com/2021/06/24/cu...assic-table-1/

          Comment


          • #6
            Thanks everyone,
            Both suggestions are very helpful, Rich's suggestion solved the problem.
            Kind regards
            AM MA

            Comment

            Working...
            X